package com.study.ratelimit.controller;

import javax.validation.Valid;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.study.ratelimit.annotation.RateLimiter;
import com.study.ratelimit.controller.vo.UserVo;
import com.study.ratelimit.utils.ReturnMsg;

import cn.hutool.core.lang.Dict;
import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;

@RestController
public class TestController {
	
	Log log = LogFactory.get();

    @RateLimiter(value = 1.0, timeout = 300)
    @GetMapping("/test1")
    public Dict test1() {
        log.info("【test1】被执行了。。。。。");
        return Dict.create().set("msg", "hello,world!").set("description", "别想一直看到我，不信你快速刷新看看~");
    }

    @GetMapping("/test2")
    public Dict test2() {
        log.info("【test2】被执行了。。。。。");
        return Dict.create().set("msg", "hello,world!").set("description", "我一直都在，卟离卟弃");
    }
    
    @GetMapping("/test3")
    public ReturnMsg test3(@Valid UserVo user) {
    	
    	return ReturnMsg.success("验证成功");
    }
}
